clear all
clc

cd('../../../../cvx_2.2.2')
cvx_setup

warning('off','MATLAB:nargchk:deprecated')
warning('off','MATLAB:illConditionedMatrix')

cd('../bernstein_simulations/J3/codes')

%% DGP

J = 3;    % # of goods
N = 20000;  % # of individuals

alpha = 1;
beta = 1;

mu_x = 0;
mu_z = 0;

sigma_x = 1;
sigma_z = 1;

fractions = [0.5 0.5];

%% PREP FOR ESTIMATION

m_regr = [3 4 3*ones(1,J-2) 4 4 3*ones(1,J-2)];

[combos_all_unique] = combinations_10(m_regr,J);

% constraints

[Aineq,bineq] = constraint_mat_theta_2(combos_all_unique,J);

Aeq = [];
beq = [];

ntheta = size(Aineq,2);

ss=96;

rng(10101010*ss+ss^2)

tic

[data,data_trans] = generate_data_rand(N,J,mu_x,sigma_x,mu_z,sigma_z,alpha,beta,fractions);

%% ESTIMATION ROUTINE

[theta_NPD,fval_NPD,flag_NPD] = estimation_NPD_cvx(data_trans,J,N,m_regr,Aineq,Aeq,bineq,beq,...
    combos_all_unique,ntheta);

toc

save('../results/random/MC_96.mat')

script_ratio

clear data* bineq Aineq input_list output_list

cd('../results/random')

save('MC_96.mat')



